<%@ Page Title="Data Dictionary" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="DataDictionary.aspx.cs" Inherits="CARMS.Admin.DataDictionary" %>

<%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls"
    TagPrefix="NineRays" %>
<%@ Register Src="~/Controls/LoadingProgress.ascx" TagName="LoadingProgress" TagPrefix="Ucc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script language="javascript" type="text/javascript">
        function OpenCreateTypeWindown() {
            $dialog('<%=ResolveUrl("~/Admin/DictionaryTypeCreate.aspx") %>', { width: 350, height: 150 }, function(result) {
                if (result == true) {
                    $get('<%=btnCreateTypeHidden.ClientID %>').click();
                    return true;
                }
                else {

                    return false;
                }
            });
        }
        function OpenCreateItemWindow(typeID) {
            $dialog('<%=ResolveUrl("~/Admin/DictionaryItemCreate.aspx?TypeID=") %>' + typeID, { width: 350, height: 150 }, function(result) {
                if (result == true) {
                    $get('<%=btnCreateItemHidden.ClientID %>').click();
                    return true;
                }
                else {

                    return false;
                }
            });
        }

        function OpenEditItemWindow(itemID) {
            $dialog('<%=ResolveUrl("~/Admin/DictionaryItemCreate.aspx?ItemID=") %>' + itemID, { width: 350, height: 150 }, function(result) {
                if (result == true) {
                    $get('<%=btnCreateItemHidden.ClientID %>').click();
                    return true;
                }
                else {

                    return false;
                }
            });
        }       
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="5" cellspacing="5">
                <tr>
                    <td>
                        <div>
                            <asp:Button ID="btnCreateType" runat="server" Text="Add New Category" OnClientClick="return OpenCreateTypeWindown();"
                                SkinID="Button150" />
                            <asp:Button ID="btnCreateTypeHidden" runat="server" SkinID="Hidden" OnClick="btnCreateType_Click" />
                        </div>
                    </td>
                    <td>
                        <div>
                            <asp:Button ID="btnCreateItem" runat="server" Text="Add New Item" OnClick="btnCreateItem_Click"
                                SkinID="Button150" Visible="false" />
                            <asp:Button ID="btnCreateItemHidden" runat="server" SkinID="Hidden" OnClick="btnCreateItemHidden_Click" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="left">
                        <asp:ListBox ID="ddlDicType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlDicType_SelectedIndexChanged"
                            SelectionMode="Single"  Width="180px" Height="450px"></asp:ListBox>
                    </td>
                    <td valign="top" align="left">
                        <table border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td>
                                    <asp:GridView ID="gridItem" runat="server" AutoGenerateColumns="false" OnRowCommand="gridItem_RowCommand"
                                        OnRowDataBound="gridItem_RowDataBound">
                                        <Columns>
                                            <asp:TemplateField HeaderText="Operation" ItemStyle-Width="120px" HeaderStyle-Width="80px">
                                                <ItemTemplate>
                                                    <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" CommandName="DeleteItem"
                                                        CausesValidation="false" CommandArgument='<%#Eval("OID") %>' OnClientClick="return ConfirmDeleteScript();"
                                                        Visible="false" />
                                                    <asp:ImageButton ID="btnModify" SkinID="Modify" runat="server" CommandName="ModifyItem"
                                                        CausesValidation="false" />
                                                    <asp:ImageButton ID="btnMoveUp" SkinID="MoveUp" runat="server" CommandName="MoveUpItem"
                                                        CausesValidation="false" Visible="false" />
                                                    <asp:ImageButton ID="btnMoveDown" SkinID="MoveDown" runat="server" CommandName="MoveDownItem"
                                                        CausesValidation="false" Visible="false" />
                                                </ItemTemplate>
                                                <HeaderStyle Width="80px" />
                                                <ItemStyle Width="120px" />
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="Name">
                                                <ItemTemplate>
                                                    <div title='<%#Eval("Name") %>'>
                                                        <%#Eval("Name")%>
                                                    </div>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                    </asp:GridView>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress runat="server">
        <ProgressTemplate>
            <Ucc:LoadingProgress runat="server" />
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
